import { platformOrderListColumns } from './platformOrderList.config.js'
import search from './../search/search.js';
import { distributioninfopage,distributioninfo } from '@/api/supplier/distributionOrder.js'
export default {
    name: "platformOrderList",
    mixins: [search],
    data() {
        return {
            platformOrderListColumns,
            loading: false,
            loadData: [{
                id: 1,
            }],
            page: {
                current: 1,
                total: 0,
                size: 10
            },
            selectedRows: [],//选中的数组
            selectedRowKeys: [],  //选中的数组
            number: 0,
            btn: [
                {
                    title: "导出",
                    isShow: true
                },
            ],
            searchForm:{}
        }
    },
    filters: {
        status(val) {
            let obj = ''
            switch (val) {
                case '00':
                    obj = '待配送'
                    break;
                case '01':
                    obj = '配送中'
                    break;
                case '02':
                    obj = '配送完成'
                    break;
                case '03':
                    obj = '平台采购作废'
                    break;
            }
            return obj
        }

    },
    methods: {
        getList( page) {
            
            if (page) {
                this.page.current = page
            }
            distributioninfopage(Object.assign({deptId: this.$store.getters.userInfo.sysUser.deptId, tenantId: this.$store.getters.userInfo.sysUser.tenantId},this.searchForm,this.page)).then(val => {
                console.log(val)
                let data = val.data
                this.page = {
                    current: data.current,
                    total: data.total,
                    size: data.size,
                }
                this.loadData = data.records
                this.$emit("trigger")
            })
        },
        onShowSizeChange(current, size) {
            console.log('onShowSizeChange',current, size)
            this.page.current = current
            this.page.size = size
            this.getList()
        },
        onSelectChange(selectedRowKeys, selectedRows) {
            this.selectedRowKeys = selectedRowKeys
            this.selectedRows = selectedRows;
            this.number = this.selectedRows.length
        },
        // 清空选中项
        clearSelection() {
            this.selectedRowKeys = []
            this.number = 0
        },
        handler(index) {
            if (index == 0) {
                this.platformOrderList()
            }
        },
        // 导出
        platformOrderList() {

        },
        peisong(item) {
            console.log(item);
            var that = this
            this.$confirm({
                title: '是否配送订单号为' + item.distributionInfoId + '的商品吗？',
                onOk() {
                    distributioninfo({ distributionInfoId: item.distributionInfoId, purchaseInfoId: item.purchaseInfoId }).then(val => {
                        that.getList()
                        that.$message.success('配送成功')
                    })
                },
                class: 'test',
            });
        },
        details(item) {
            this.$router.push({
                path: "/supplier/distributionOrder/platformOrderList/inDetails", query: {
                    distributionInfoId: item.distributionInfoId,
                    status:item.status
                }
            })
        }
    }

} 